<br />
<?php
if (!defined('PATH'))
	exit();
?>
<table border='0' cellpadding='8' cellspacing='1' width='100%'>
	<tr class='head'><td colspan='3' align='center'><b>Top Sellers</b></td></tr>
	<tr class='bold'><td width="5%" align="center">#</td><td width="65%">Name</td><td width="30%" align="center">Purchased</td></tr>
<?php
$query = $SQL->query('SELECT COUNT(*) as `allcount`, `__archez_store_items`.* FROM `__archez_store_record` JOIN `__archez_store_items` ON (`__archez_store_items`.`id` = `__archez_store_record`.`offer_id`) GROUP BY `__archez_store_record`.`offer_id` ORDER BY `allcount` DESC LIMIT 5');
$i = 0;

foreach ($query as $result) {
$i++;
	echo '<tr><td style="text-align:center;">' . $i .'.</td><td>' . ucfirst($result['name']) . ' <td style="text-align:center;">' . $result['allcount'] . ' ';
	if ($result['allcount'] == 1) {
		echo 'time';
	} else {
		echo 'times';
	}
	echo '
	</td>
	</td>
	</tr>';
}
if (empty($query)) {
	echo '<tr><td style="text-align:center;" colspan="3">Empty</td></tr>';
}
?>
</table>